﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongHoc_App.MyControls
{
    public partial class LogInControl : UserControl
    {
        public delegate void EventUpdate(object sender);
        public event EventUpdate LogIn;

        public LogInControl()
        {
            InitializeComponent();
        }

        public String UsernameText
        {
            get { return lbUserName.Text; }
            set { lbUserName.Text = value; }
        }

        public String PasswordText
        {
            get { return lbPassWord.Text; }
            set { lbPassWord.Text = value; }
        }

        public String Username
        {
            get { return tbUserName.Text; }
            set { tbUserName.Text = value; }
        }

        public String Password
        {
            get { return tbPassword.Text; }
            set { tbPassword.Text = value; }
        }

        public String LogInText
        {
            get { return btLogIn.Text; }
            set { btLogIn.Text = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                LogIn(this);
            }
            catch { }
        }

        private void LogInControl_Resize(object sender, EventArgs e)
        {
            tbPassword.Width = tbUserName.Width = this.Width - tbUserName.Left - 3;
            btLogIn.Left = this.Width - 3 - btLogIn.Width;

        }

        private void tbUserName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                button1_Click(btLogIn, new EventArgs());
        }
    }
}
